﻿/* ==================
脚本作者：风雨
联系方式：609654666
=====================
 */
importPackage(Packages.handling.word);
importPackage(Packages.client.inventory);
importPackage(java.lang);
importPackage(Packages.tools);
importPackage(Packages.client);
importPackage(Packages.server);
importPackage(Packages.tools.packet);
var 红蓝点 = "#fEffect/CharacterEff.img/1032054/0/0#";
var 蓝星 = "#fEffect/CharacterEff.img/1052203/1/0#";
var 红星 = "#fEffect/CharacterEff.img/1052203/2/0#";
var 大蓝星 = "#fEffect/CharacterEff.img/1022223/2/0#";
var 大红星 = "#fEffect/CharacterEff.img/1022223/1/0#";
var 蓝点 = "#fEffect/CharacterEff.img/1022223/6/0#";
var 红点 = "#fEffect/CharacterEff.img/1022223/7/0#";
var 奖励 = "#fUI/UIWindow.img/Quest/reward#";
var 正在进行 = "#fUI/UIWindow.img/Quest/Tab/enabled/1#";
var 任务简述 = "#fUI/UIWindow.img/Quest/summary#";
var 经验值 = "#fUI/UIWindow.img/QuestIcon/8/0#";
var 金币 = "#fUI/UIWindow.img/QuestIcon/7/0#";
var UP = "#fUI/UIWindow.img/Family/RightIcon/4#";
var 分割线 = "#fUI/CashShop.img/CSDiscount/Line#";

var 每日可打工 = 2;

var 格子 = 0;
var itemList = Array(//定义物品材料
    //Array(品阶,物品id),
    Array("C", 1382000),
    Array("C", 1092007),
    Array("C", 1402009),
    Array("C", 1082012),
    Array("C", 1432008),
    Array("C", 1412012),
    Array("C", 1072019),
    Array("C", 1072073),
    Array("C", 1082000),
    Array("C", 1472006),
    Array("C", 1072085),
    Array("C", 1472009),
    Array("C", 1472012),
    Array("C", 1072087),
    Array("C", 1002616),
    Array("C", 1032009),
    Array("C", 1032008),
    Array("C", 1432003),
    Array("C", 1312007),
    Array("C", 1492003),
    Array("C", 1032000),
    Array("C", 1032002),
    Array("C", 1002064),
    Array("C", 1072033),
    Array("C", 1072039),
    Array("C", 1402006),
    Array("C", 1382017),
    Array("C", 1002151),
    Array("C", 1452005),
    Array("C", 1462004),
    Array("C", 1412005),
    Array("C", 1002058),
    Array("C", 1072053),
    Array("C", 1082043),
    Array("C", 1082006),
    Array("C", 1082026),
    Array("C", 1302002),
    Array("C", 1372004),
    Array("C", 1082049),
    Array("C", 1082051),
    Array("C", 1061019),
    Array("C", 1041023),
    Array("C", 1040021),
    Array("C", 1040043),
    Array("C", 1060032),
    Array("C", 1032006),
    Array("C", 1082037),
    Array("C", 1322009),
    Array("C", 1332014),
    Array("C", 1061047),
    Array("C", 1082046),
    Array("C", 1432005),
    Array("C", 1002622),
    Array("C", 1332020),
    Array("C", 1082044),
    Array("C", 1002141),

    Array("B", 1412006),
    Array("B", 1032008),
    Array("B", 1040073),
    Array("B", 1060062),
    Array("B", 1052107),
    Array("B", 1472013),
    Array("B", 1051024),
    Array("B", 1050036),
    Array("B", 1032011),
    Array("B", 1322015),
    Array("B", 1082045),
    Array("B", 1041066),
    Array("B", 1060020),
    Array("B", 1041053),
    Array("B", 1002037),
    Array("B", 1302017),
    Array("B", 1002153),
    Array("B", 1082025),
    Array("B", 1072115),
    Array("B", 1482005),
    Array("B", 1050031),
    Array("B", 1082071),
    Array("B", 1332011),
    Array("B", 1052110),
    Array("B", 1382019),
    Array("B", 1082192),
    Array("B", 1072119),
    Array("B", 1082063),
    Array("B", 1072110),
    Array("B", 1092013),
    Array("B", 1472017),
    Array("B", 1322003),
    Array("B", 1412004),
    Array("B", 1082047),
    Array("B", 1482006),
    Array("B", 1092021),
    Array("B", 1002045),
    Array("B", 1382001),
    Array("B", 1050046),
    Array("B", 1302010),
    Array("B", 1332016),
    Array("B", 1072125),
    Array("B", 1052113),
    Array("B", 1072124),
    Array("B", 1041089),
    Array("B", 1061088),
    Array("B", 1072142),
    Array("B", 1092004),
    Array("B", 1072303),
    Array("B", 1082084),
    Array("B", 1072132),
    Array("B", 1002098),
    Array("B", 1072140),
    Array("B", 1082066),
    Array("B", 1462006),
    Array("B", 1462007),
    Array("B", 1442005),
    Array("B", 1332003),
    Array("B", 1302013),
    Array("B", 1002212),
    Array("B", 1322017),
    Array("B", 1472019),
    Array("B", 1050051),
    Array("B", 1302016),
    Array("B", 1002217),
    Array("B", 1412003),
    Array("B", 1482007),
    Array("B", 1040095),
    Array("B", 1082036),
    Array("B", 1082045),
    Array("B", 1040081),
    Array("B", 1040030),
    Array("B", 1051030),
    Array("B", 1452008),
    Array("B", 1402007),
    Array("B", 1092029),
    Array("B", 1382000),
    Array("B", 1092007),
    Array("B", 1402009),
    Array("B", 1082012),
    Array("B", 1432008),
    Array("B", 1412012),
    Array("B", 1072019),
    Array("B", 1072073),
    Array("B", 1082000),
    Array("B", 1472006),
    Array("B", 1072085),
    Array("B", 1472009),
    Array("B", 1472012),
    Array("B", 1072087),
    Array("B", 1002616),
    Array("B", 1032009),
    Array("B", 1032008),
    Array("B", 1432003),
    Array("B", 1312007),
    Array("B", 1492003),
    Array("B", 1032000),
    Array("B", 1032002),
    Array("B", 1002064),
    Array("B", 1072033),
    Array("B", 1072039),
    Array("B", 1402006),
    Array("B", 1382017),
    Array("B", 1002151),
    Array("B", 1452005),
    Array("B", 1462004),
    Array("B", 1412005),
    Array("B", 1002058),
    Array("B", 1072053),
    Array("B", 1082043),
    Array("B", 1082006),
    Array("B", 1082026),
    Array("B", 1302002),
    Array("B", 1372004),
    Array("B", 1082049),
    Array("B", 1082051),
    Array("B", 1061019),
    Array("B", 1041023),
    Array("B", 1040021),
    Array("B", 1040043),
    Array("B", 1060032),
    Array("B", 1032006),
    Array("B", 1082037),
    Array("B", 1322009),
    Array("B", 1332014),
    Array("B", 1061047),
    Array("B", 1082046),
    Array("B", 1432005),
    Array("B", 1002622),
    Array("B", 1332020),
    Array("B", 1082044),
    Array("B", 1002141),

    Array("A", 1432004),
    Array("A", 1312008),
    Array("A", 1422005),
    Array("A", 1412005),
    Array("A", 1432005),
    Array("A", 1452007),
    Array("A", 1302030),
    Array("A", 1492020),
    Array("A", 1482020),
    Array("A", 1332025),
    Array("A", 1412011),
    Array("A", 1432012),
    Array("A", 1452022),
    Array("A", 1472032),
    Array("A", 1462019),
    Array("A", 1382012),
    Array("A", 1412006),
    Array("A", 1472013),
    Array("A", 1322015),
    Array("A", 1302017),
    Array("A", 1482005),
    Array("A", 1332011),
    Array("A", 1382019),
    Array("A", 1472017),
    Array("A", 1322003),
    Array("A", 1412004),
    Array("A", 1482006),
    Array("A", 1382001),
    Array("A", 1302010),
    Array("A", 1332016),
    Array("A", 1462006),
    Array("A", 1462007),
    Array("A", 1442005),
    Array("A", 1332003),
    Array("A", 1302013),
    Array("A", 1322017),
    Array("A", 1472019),
    Array("A", 1302016),
    Array("A", 1412003),
    Array("A", 1482007),
    Array("A", 1452008),
    Array("A", 1402007),
    Array("A", 1382000),
    Array("A", 1402009),
    Array("A", 1432008),
    Array("A", 1412012),
    Array("A", 1472006),
    Array("A", 1472009),
    Array("A", 1472012),
    Array("A", 1432003),
    Array("A", 1312007),
    Array("A", 1492003),
    Array("A", 1402006),
    Array("A", 1382017),
    Array("A", 1452005),
    Array("A", 1462004),
    Array("A", 1412005),
    Array("A", 1302002),
    Array("A", 1372004),
    Array("A", 1322009),
    Array("A", 1332014),
    Array("A", 1432005),
    Array("A", 1332020),

    Array("S", 1452044),
    Array("S", 1452021),
    Array("S", 1462039),
    Array("S", 1462017),
    Array("S", 1332049),
    Array("S", 1332050),
    Array("S", 1332051),
    Array("S", 1332052),
    Array("S", 1472052),
    Array("S", 1472051),
    Array("S", 1472053),
    Array("S", 1472033),
    Array("S", 1482013),
    Array("S", 1482012),
    Array("S", 1492013),
    Array("S", 1492012),
    Array("S", 1372032),
    Array("S", 1372010),
    Array("S", 1382036),
    Array("S", 1382035),
    Array("S", 1442045),
    Array("S", 1442044),
    Array("S", 1432038),
    Array("S", 1432030),
    Array("S", 1302056),
    Array("S", 1302059),
    Array("S", 1422027),
    Array("S", 1422028),
    Array("S", 1312030),
    Array("S", 1312031),
    Array("S", 1322029),
    Array("S", 1322045),
    Array("S", 1402005),
    Array("S", 1402036),
    Array("S", 1412021),
    Array("S", 1412026)
);

var jl = Array(//阶段奖励材料    按照阶段 全部都是固定给
    //Array(品阶,最小等级,最大等级),

    Array("C", 1, 69), //武器+防具+首饰
    Array("B", 70, 99), //武器+防具+首饰
    Array("A", 100, 119), //武器+10g
    Array("S", 120, 255)); //武器+10g

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == 1)
        status++;
    else {
        cm.dispose();
        return;
    }
    if (status == 0) {
        打工状态 = cm.getPlayer().getOneTimeLog("打工状态");
        今日完成打工 = cm.getPlayer().getBossLog("今日完成打工");
        任务品阶 = 获取任务品阶();
        var text = "" + 任务简述 + "\r\n";
        text += "#d你目前的打工阶段为#r" + 任务品阶 + "#d阶段\r\n"
        text += "#k提交任务请把道具放在装备窗第一格\r\n"
        text += "打工分为10-69/70-99/100-119/120-255（4个阶段）\r\n"
        text += "100级以上阶段的所需武器另有属性要求\r\n"
        text += "#d阶段随着角色等级变化而变化。每日可打工" + 每日可打工 + "次\r\n"
        text += "#d今日完成打工[#r" + 今日完成打工 + "#d/" + 每日可打工 + "]\r\n"
        text += "#d" + 分割线 + "\r\n"
        text += "#L10#" + 经验值 + "比例查询#l    "
        if (打工状态 == 0) { //没接任务

            if (今日完成打工 < 每日可打工) {
                text += "#L0##r开始打工" + 奖励 + "#l"
            } else {
                text += "#d今日已经完成！！！！！[#r" + 今日完成打工 + "#d/" + 每日可打工 + "]\r\n"
            }

        } else { //接任务了
            var ss = 获取任务信息();
            text = "#L6##r#e提交打工任务#l#L7##d2000交易币重置本次打工#l\r\n#L8##d查该物品出处#l\r\n\r\n"
            text += "#d" + 任务简述 + "" + 分割线 + "\r\n"
            text += "#n#d任务品阶：#r " + 任务品阶 + " #d阶\r\n"
            text += "#d任务物品：#v" + 物品id + "# * " + 物品数量 + "  [#r" + cm.getPlayer().getItemQuantity(物品id, false) + "#d/" + 物品数量 + "]\r\n"
            if (任务品阶 == "A" || 任务品阶 == "S") {
                if (需求装备攻种 == 2) {
                    text += "#d需求装备魔攻#r+" + 需求装备攻击 + "#d以上\r\n"
                }
                if (需求装备攻种 == 1) {
                    text += "#d需求装备物攻#r+" + 需求装备攻击 + "#d以上\r\n"
                }
            }
            text += "\r\n#d" + 奖励 + "#e" + 分割线 + "#n\r\n"
            text += ss;

        }

        cm.sendSimple(text);
    } else if (status == 1) {
        if (selection == 10) {
            cm.sendOk("10-70级C阶段给予：40%经验,500抵用.\r\n70-99级B阶段给予：30%经验,1000抵用.\r\n100-120级A阶段给予：20%经验,2000抵用.\r\n120级以上S阶段给予：10%经验,3000抵用.");
            cm.dispose();
            return;
        }
        var ss = "";
        switch (selection) {
            case 0: //c
                ss = 接任务(任务品阶);
                break;
            case 6: //提交任务
                if (cm.getPlayer().getItemQuantity(物品id, false) < 物品数量) {
                    text = "任务信息：物品不足\r\n";
                    text += "#d" + 分割线 + "\r\n"
                    text += "#d任务品阶：#r " + 任务品阶 + " #d阶\r\n"
                    text += "#d任务物品：#v" + 物品id + "# * " + 物品数量 + "  [#r" + cm.getPlayer().getItemQuantity(物品id, false) + "#d/" + 物品数量 + "]\r\n"
                    cm.sendOk(text);
                    cm.dispose();
                    return;
                } else { //足够
                    for (var i = 0; i < 96; i++) {

                        if (任务品阶 == "A" || 任务品阶 == "S") {
                            if (cm.getInventory(1).getItem(i) != null && cm.getInventory(1).getItem(i).getItemId() == 物品id && cm.getInventory(1).getItem(i).copy().getMatk() >= 需求装备攻击 && 需求装备攻种 == 2) {
                                ss += "#L" + i + "##i" + cm.getInventory(1).getItem(i).getItemId() + ":##l";
                            } else {
                                if (cm.getInventory(1).getItem(i) != null && cm.getInventory(1).getItem(i).getItemId() == 物品id && cm.getInventory(1).getItem(i).copy().getWatk() >= 需求装备攻击 && 需求装备攻种 == 1) {
                                    ss += "#L" + i + "##i" + cm.getInventory(1).getItem(i).getItemId() + ":##l";
                                }

                            }
                        } else {

                            if (cm.getInventory(1).getItem(i) != null && cm.getInventory(1).getItem(i).getItemId() == 物品id) {
                                ss += "#L" + i + "##i" + cm.getInventory(1).getItem(i).getItemId() + ":##l";
                            }

                        }

                    }

                    if (ss == "") {
                        cm.sendOk("没有符号要求的物品");
                        cm.dispose();
                        return;
                    } else {
                        cm.sendSimple("请选择符合的物品:（选中就会消失掉）\r\n#d" + ss);
                    }

                    /* 				if (完成任务() == true) {
                    cm.sendOk("悬赏完成！奖励发送到背包");
                    cm.dispose();
                    return;
    
                    } else {
                    cm.sendOk("悬赏完成失败！可能背包不足");
                    cm.dispose();
                    return;
    
                    } */

                }

                break;
            case 7: //重置
                if (cm.getPlayer().getOneTimeLogacs("副本交易币")< 2000) {
                    cm.sendOk("交易币不足2000无法重接取");
                    cm.dispose();
                    return;
                } else {
                    cm.killbosslog("onetimelog", "log", "打工状态");
                    //cm.gainwzcz(- 2000);
					cm.getPlayer().gainOneTimeLogacs("副本交易币",-2000)
                    cm.sendOk("成功");
                    cm.dispose();
                    return;
                }
                break;
            case 8: //查物品出处
                cm.sendOk(cm.checkDropper(物品id));
                cm.dispose();
                return;
                break;

        }

        if (selection == 0) { //任务
            text = "#d#e成功接取打工\r\n" + 分割线 + "\r\n"
            text += "任务信息：收集以下道具\r\n";
            text += "#d" + 分割线 + "\r\n"
            text += "#d任务品阶：#r " + 任务品阶 + " #d阶\r\n"
            text += "#d任务物品：#v" + 物品id + "# * " + 物品数量 + "  [#r" + cm.getPlayer().getItemQuantity(物品id, false) + "#d/" + 物品数量 + "]\r\n"
            if (ss != "") {
                text += "\r\n#r属性需求#d" + 分割线 + "\r\n"
                text += ss;
            }
            cm.sendOk(text);
            cm.dispose();
            return;
        }
    } else if (status == 2) { //提交任务

        if (完成任务() == true) {
            MapleInventoryManipulator.removeFromSlot(cm.getC(), MapleItemInformationProvider.getInstance().getInventoryType(物品id), selection, 1, false);
            if (任务品阶 == "S") {
                cm.gainD(3000);//
                cm.getPlayer().gainOneTimeLogcs("打工任务积分",+4);
            } else if (任务品阶 == "A") {
                cm.gainD(2000);//
                cm.getPlayer().gainOneTimeLogcs("打工任务积分",+3);
            } else if (任务品阶 == "B") {
                cm.gainD(1000);//
                cm.getPlayer().gainOneTimeLogcs("打工任务积分",+2);
            } else if (任务品阶 == "C") {
                cm.gainD(500);//
                cm.getPlayer().gainOneTimeLogcs("打工任务积分",+1);
            }
			cm.getPlayer().gainOneTimeLogcs("打工任务总次数",+1);
            cm.sendOk("打工完成！奖励发送到背包");
            cm.worldMessage(6, "【打工任务】玩家：[" + cm.getName() + "]完成了" + 任务品阶 + "打工任务1次!获得了大量经验UP！");
            cm.dispose();
            return;

        } else {
            cm.sendOk("打工失败！可能背包不足");
            cm.dispose();
            return;

        }

    }
}

function 获取任务信息() {
    var C经验 = new HashMap();
    //C经验.put(第一次,1%);
    C经验.put("1", "40");
    C经验.put("2", "40");
    C经验.put("3", "40");
    C经验.put("4", "40");
    C经验.put("5", "40");
    C经验.put("6", "40");
    C经验.put("7", "40");
    C经验.put("8", "40");
    C经验.put("9", "40");
    C经验.put("10", "40");
    var B经验 = new HashMap();
    //C经验.put(第一次,1%);
    B经验.put("1", "30");
    B经验.put("2", "30");
    B经验.put("3", "30");
    B经验.put("4", "30");
    B经验.put("5", "30");
    B经验.put("6", "30");
    B经验.put("7", "30");
    B经验.put("8", "30");
    B经验.put("9", "30");
    B经验.put("10", "30");
    var A经验 = new HashMap();
    //A经验.put(第一次,1%);
    A经验.put("1", "20");
    A经验.put("2", "20");
    A经验.put("3", "20");
    A经验.put("4", "20");
    A经验.put("5", "20");
    A经验.put("6", "20");
    A经验.put("7", "20");
    A经验.put("8", "20");
    A经验.put("9", "20");
    A经验.put("10", "20");
    var S经验 = new HashMap();
    //S经验.put(第一次,1%);
    S经验.put("1", "10");
    S经验.put("2", "10");
    S经验.put("3", "10");
    S经验.put("4", "10");
    S经验.put("5", "10");
    S经验.put("6", "10");
    S经验.put("7", "10");
    S经验.put("8", "10");
    S经验.put("9", "10");
    S经验.put("10", "10");

    格子 = 1;
    任务品阶 = cm.getQuestRecord(644440).getCustomData();
    物品id = Number(cm.getQuestRecord(644441).getCustomData()); //读取任务物品
    物品数量 = Number(cm.getQuestRecord(644442).getCustomData()); //读取任务个数
    需求装备攻种 = Number(cm.getQuestRecord(644443).getCustomData());
    需求装备攻击 = Number(cm.getQuestRecord(644444).getCustomData());
    百分比 = 0;
    if (任务品阶 == "C") {
        百分比 = C经验.get("" + (今日完成打工 + 1));
    }
    if (任务品阶 == "B") {
        百分比 = B经验.get("" + (今日完成打工 + 1));
    }
    if (任务品阶 == "A") {
        百分比 = A经验.get("" + (今日完成打工 + 1));
    }
    if (任务品阶 == "S") {
        百分比 = S经验.get("" + (今日完成打工 + 1));
    }
    奖励经验 = (cm.getPlayer().getNeededExp() / 100) * 百分比;
    txt = "";
    txt += "经验：" + parseInt(奖励经验) + "  (" + 百分比 + "%)\r\n";
     if (任务品阶 == "S") {
        txt += "抵用券：3000\r\n";
    } else if (任务品阶 == "A") {
        txt += "抵用券：2000\r\n";
    } else if (任务品阶 == "B") {
        txt += "抵用券：1000\r\n";
    } else if (任务品阶 == "C") {
        txt += "抵用券：500\r\n";
    } 

    return txt;
}

function 完成任务() {

    if (cm.getInventory(1).isFull(格子 - 1)) { //判断第一个也就是装备栏的装备栏是否有一个空格
        cm.sendOk("#d请保证装备栏位至少有1个空格,否则无法兑换.");
        cm.dispose();
        return false;
    } else if (cm.getInventory(2).isFull(格子 - 1)) { //判断第二个也就是消耗栏的装备栏是否有一个空格
        cm.sendOk("#d请保证消耗栏位至少有1个空格,否则无法兑换.");
        cm.dispose();
        return false;
    } else if (cm.getInventory(3).isFull(格子 - 1)) { //判断第三个也就是设置栏的装备栏是否有一个空格
        cm.sendOk("#d请保证设置栏位至少有1个空格,否则无法兑换.");
        cm.dispose();
        return false;
    } else if (cm.getInventory(4).isFull(格子 - 1)) { //判断第四个也就是其它栏的装备栏是否有一个空格
        cm.sendOk("#d请保证其它栏位至少有1个空格,否则无法兑换.");
        cm.dispose();
        return false;
    }

    //任务品阶 =cm.getQuestRecord(544440).getCustomData();
    //物品id = Number(cm.getQuestRecord(544441).getCustomData()); //读取任务物品
    //物品数量 = Number(cm.getQuestRecord(544442).getCustomData()); //读取任务个数

	/* 	            cm.gainItem(物品id, -物品数量);
	cm.gainMeso(当前环数 * 全局金币倍率); //给金币全局经验倍率
	cm.gainExp(当前环数 * 全局经验倍率); //给经验 */
    cm.gainExp(奖励经验);
    cm.killbosslog("onetimelog", "log", "打工状态");
    cm.getPlayer().setBossLog("今日完成打工");

    return true;
}

function 接任务(a) {
    var 物品组 = Array();
    任务品阶 = a;
    txt = "";
    for (var j = 0; j < itemList.length; j++) {
        if (itemList[j][0] == a) { //判断物品标识
            物品组.push(itemList[j][1]);
        }
    }

    物品id = 物品组[Math.floor(Math.random() * 物品组.length)];
    //Array(品阶,物品id,需求装备魔攻,需求装备物攻),

    物品数量 = 1;
    cm.getQuestRecord(644440).setCustomData(a);
    cm.getQuestRecord(644441).setCustomData("" + 物品id);
    cm.getQuestRecord(644442).setCustomData("" + 物品数量);
    var 随机 = Math.floor(Math.random() * (10 - 5 + 1) + 5);
    if (任务品阶 == "A" || 任务品阶 == "S") {
        switch (parseInt(物品id / 10000)) {
            case 130: //单手剑
            case 131: //单手斧
            case 132: //单手钝器
            case 140: //双手剑
            case 141: //双手斧
            case 142: //双手钝器
            case 143: //长枪
            case 144: //矛
            case 149: //短枪
            case 148: //指节
            case 147: //拳套
            case 133: //短刃
            case 145: //弓
            case 146: //弩
                需求装备物攻 = (MapleItemInformationProvider.getInstance().getEquipById(物品id).copy().getWatk() + 随机);
                cm.getQuestRecord(644443).setCustomData("1");
                cm.getQuestRecord(644444).setCustomData("" + 需求装备物攻);
                txt += "#d需求装备物攻:#r" + 需求装备物攻 + "#d\r\n"
                break;
            default:
                需求装备魔攻 = (MapleItemInformationProvider.getInstance().getEquipById(物品id).copy().getMatk() + 随机);
                cm.getQuestRecord(644443).setCustomData("2");
                cm.getQuestRecord(644444).setCustomData("" + 需求装备魔攻);
                txt += "#d需求装备魔攻:#r" + 需求装备魔攻 + "#d\r\n"
                break;

        }

    }

    cm.getPlayer().setOneTimeLog("打工状态");
    cm.getPlayer().saveToDB(false, false);
    return txt;
}
function 获取任务品阶() {

    //Array(品阶,最小等级,最大等级),
    for (var j = 0; j < jl.length; j++) {
        if (jl[j][2] >= cm.getPlayer().getLevel() && jl[j][1] <= cm.getPlayer().getLevel()) {
            return jl[j][0];
        }
    }

}

function HashMap() {
	/**
	 * *********  操作实例  **************
	 *   var map = new HashMap();
	 *   map.put("key1","Value1");
	 *   map.put("key2","Value2");
	 *   map.put("key3","Value3");
	 *   map.put("key4","Value4");
	 *   map.put("key5","Value5");
	 *   alert("size："+map.size()+" key1："+map.get("key1"));
	 *   map.remove("key1");
	 *   map.put("key3","newValue");
	 *   var values = map.values();
	 *   for(var i in values){
	 *       document.write(i+"："+values[i]+"   ");
	 *   }
	 *   document.write("<br>");
	 *   var keySet = map.keySet();
	 *   for(var i in keySet){
	 *       document.write(i+"："+keySet[i]+"  ");
	 *   }
	 *   alert(map.isEmpty());
	 */
    //定义长度
    var length = 0;
    //创建一个对象
    var obj = new Object();

	/**
	 * 判断Map是否为空
	 */
    this.isEmpty = function () {
        return length == 0;
    };

	/**
	 * 判断对象中是否包含给定Key
	 */
    this.containsKey = function (key) {
        return (key in obj);
    };

	/**
	 * 判断对象中是否包含给定的Value
	 */
    this.containsValue = function (value) {
        for (var key in obj) {
            if (obj[key] == value) {
                return true;
            }
        }
        return false;
    };

	/**
	 *向map中添加数据
	 */
    this.put = function (key, value) {
        if (!this.containsKey(key)) {
            length++;
        }
        obj[key] = value;
    };

	/**
	 * 根据给定的Key获得Value
	 */
    this.get = function (key) {
        return this.containsKey(key) ? obj[key] : null;
    };

	/**
	 * 根据给定的Key删除一个值
	 */
    this.remove = function (key) {
        if (this.containsKey(key) && (delete obj[key])) {
            length--;
        }
    };

	/**
	 * 获得Map中的所有Value
	 */
    this.values = function () {
        var _values = new Array();
        for (var key in obj) {
            _values.push(obj[key]);
        }
        return _values;
    };

	/**
	 * 获得Map中的所有Key
	 */
    this.keySet = function () {
        var _keys = new Array();
        for (var key in obj) {
            _keys.push(key);
        }
        return _keys;
    };

	/**
	 * 获得Map的长度
	 */
    this.size = function () {
        return length;
    };

	/**
	 * 清空Map
	 */
    this.clear = function () {
        length = 0;
        obj = new Object();
    };
}
